home *** CD-ROM | disk | FTP | other *** search
/ Cocktail Hour / image.iso / COCKTAIL.DIR / 00054_Script_MaxPrint v3.0 < prev    next >
Text File  |  1997-03-05  |  17KB  |  468 lines

  1. -- MaxPrint version 3.0 --
  2.  
  3. on MaxPrint printType
  4.   
  5.   cursor 4
  6.   
  7.   -- the main script activates the procedures for text,tour or map printing --
  8.   global gPropFont,printer
  9.   --set the itemdelimiter to "~"
  10.   put "times new roman" into gPropFont
  11.   openxlib "pmatic.dll"
  12.   put PrintOMatic(mnew) into printer
  13.   printer(mRegister,"pmat130-067-01107")
  14.   printer(mReset)
  15.   if printType="map" then
  16.     printmap
  17.   else if printType="tour" then
  18.     printTour
  19.   else if printType="text" then
  20.     printText
  21.   end if
  22.   printer(mDispose)
  23.   closexlib "pmatic.dll"
  24.   
  25.   cursor -1
  26. end 
  27.  
  28. on printMap 
  29.   -- printMap prints the map and its "you are here" arrow. --
  30.   global w,h,print
  31.   if item 5 of field "MaxField"="metro" then
  32.     -- if there are maps which are portrait mode, which only happened in paris --
  33.     -- up to now, the word metro should be removed from the maxfield --
  34.     printer (mSetLandScapemode,TRUE)
  35.   else
  36.     printer (mSetLandScapemode,FALSE)
  37.   end if
  38.   set mapToPrint=the value of item 1 of field "MaxField"
  39.   put printer(mGetPageWidth) into w
  40.   put printer(mGetPageheight) into h
  41.   -- this part deals with printing the headline of the map --
  42.   set mapName=item 4 of field "maxfield"
  43.   printer (mSetMargins,1,1,1,1)
  44.   printer (mSetTextStyle,"bold,underline")
  45.   --set halve=w/2-(24*(the number of chars of mapName)/2)
  46.   set halve=printer(mGetPaperWidth)/2
  47.   printer (mSetTextSize,24)
  48.   --printer (mTextBox,halve,30,(24*(the number of chars of mapName)),54,FALSE)
  49.   printer (mSetTextJust,"centered")
  50.   printer (mdrawText,mapName,halve,40)
  51.   
  52.   printer (mNewPage)
  53.   --set mapy=the height of cast mapToPrint
  54.   --set mapx=the width of cast mapToPrint
  55.   --set halve=w/2-mapX/2
  56.   if item 5 of field "MaxField"="metro" then
  57.     AppendBitMap(mapToPrint,1,55,"metro")
  58.   else
  59.     AppendBitMap(mapToPrint,1,55,"map")
  60.   end if
  61.   if item 2 of field "MaxField">-1 then
  62.     -----------------------------------------------------------------------------
  63.     -- printing an arrow on the map, is conditioned by the second item in the  --
  64.     -- line ordering the print, not being -1. the parameters for the arrow are --
  65.     -- being held in the second and third parameters. The zero point is,       --
  66.     -- currently set at 1,55 of the page's setup.                            --
  67.     -----------------------------------------------------------------------------
  68.     
  69.     set arrowx=the value of item 2 of field "MaxField"
  70.     set arrowy=the value of item 3 of field "MaxField"
  71.     
  72.     AppendBitMap("arrow",arrowx,arrowy,"arrow")
  73.   end if
  74.   printingProc
  75. end 
  76.  
  77. on appendBitMap TheBitMap,left,top,whatToPrint
  78.   ------------------------------------------------------------------------------
  79.   -- TheBitMap is the name of the bitmap to be printed, left and top are its  --
  80.   -- left and top coordinates and whatToPrint specifies which object is being --
  81.   -- printed for specific conditions                                          --
  82.   -- w is the width of the screen. h is the height of the screen, forArrow is --
  83.   -- a variable set when a map is printed, for its arrow's coordinates        --
  84.   ------------------------------------------------------------------------------
  85.   global w,h,print,forArrowTop,forArrowLeft,prop
  86.   
  87.   set y=the height of cast TheBitMap
  88.   set x=the width of cast TheBitMap
  89.   
  90.   if whatToPrint="tour" then
  91.     ----------------------------------------------------------------------------
  92.     -- if the bitmap is a tour, (or any other standard bitmap), the condition --
  93.     -- will prevent it from being bigger than the page.                       --
  94.     ----------------------------------------------------------------------------
  95.     if  x>w-5 then
  96.       set x=w-5
  97.       set y=y*w/x+30
  98.     end if
  99.     
  100.   else if whatToPrint="map" then
  101.     ------------------------------------------------------------------------------
  102.     -- if the bitmap is a map, it will be shrinked accorddingly from both sides --
  103.     -- to fit the page, and be set to be smaller then the page.                 --
  104.     ------------------------------------------------------------------------------
  105.     set oldY=y
  106.     set oldX=x
  107.     set y=printer(mGetPageHeight)-top-60
  108.     set x=oldX*y/oldY+0.0
  109.     set prop=y/(oldY+0.0)
  110.     set left=(printer(mGetPageWidth))/2.0-x/2.0
  111.     set x=left+x
  112.     set y=top+y
  113.     set forArrowTop=top
  114.     set forArrowLeft=left
  115.     set left=integer(left)
  116.     set x=integer(x)
  117.   else  if whatToPrint="metro" then
  118.     set oldY=y
  119.     set oldX=x
  120.     set x=printer(mGetPageWidth)
  121.     set y=oldY*x/oldX+0.0
  122.     set prop=x/(oldX+0.0)
  123.     set top=(printer(mGetPageHeight))/2.0-y/2.0
  124.     set x=left+x
  125.     set y=top+y
  126.     set forArrowTop=top
  127.     set forArrowLeft=left
  128.     set top=integer(top)
  129.     set y=integer(y)
  130.   else if whatToPrint="arrow" then
  131.     --global prop
  132.     -------------------------------------------------------------------------
  133.     -- if what to print is an arrow, left and top actually hold its center --
  134.     -- so all of the sides need to be calculated                           --
  135.     -------------------------------------------------------------------------
  136.     
  137.     set left=left*prop
  138.     set top=top*prop
  139.     if item 5 of field "MaxField"="metro" then
  140.       --set top=top-20
  141.       --set left=left-5
  142.     end if
  143.     set left=integer(left-x/2+forArrowLeft)
  144.     set top=integer(top-y+forArrowTop)
  145.     set top=top-7
  146.     set x=integer(left+x)
  147.     set y=integer(top+y)
  148.     
  149.   end if
  150.   
  151.   printer (mPicture,the picture of member TheBitMap,left,top,x,y)
  152.   -- this sets the first textbox after the tour bitmap is printed --
  153.   if whatToPrint="tour" then
  154.     --printer (mTextBox,45,y+20,printer(mGetPageWidth),printer(mGetPageHeight),TRUE)
  155.   end if
  156. end 
  157.  
  158.  
  159. on PrintText
  160.   -- printText prints text casts --
  161.   global w,h,gPropFont,printer
  162.   
  163.   --if not objectP(printer) then
  164.   -- something went wrong, the Xtra was not instantiated
  165.   -- Alert "There is no currently selected printer. Printing features are disabled."
  166.   -- else
  167.   
  168.   -- set the page margins
  169.   printer (mSetMargins,72,72,72,72)
  170.   
  171.   put printer (mGetPageWidth) into w
  172.   put printer (mGetPageHeight) into h
  173.   MySetUp
  174.   -- set up the  template page with one text box
  175.   printer (mNewPage)
  176.   printer (mTextBox,22,42,w,h,false)
  177.   -- this loop will append all of the casts specified in "MaxField"
  178.   repeat with cnt = 1 to the number of lines of field "MaxField"
  179.     set CastToPrint=integer(the value of item 1 of line cnt of field "Maxfield")
  180.     AppendStyledText (printer, CastToPrint, TRUE)
  181.   end repeat
  182.   
  183.   printingProc
  184. end
  185.  
  186. on printTour
  187.   -- printTour prints tours, which consist of both bitmaps and texts --
  188.   global printer
  189.   
  190.   put printer (mGetPageWidth) into w
  191.   put printer (mGetPageHeight) into h
  192.   MySetUp
  193.   printer (mNewPage)
  194.   set mapName=line 1 of field "maxfield"
  195.   printer (mSetMargins,1,1,1,1)
  196.   printer (mSetTextStyle,"bold,underline")
  197.   --set halve=w/2-(24*(the number of chars of mapName)/2)
  198.   set halve=printer(mGetPaperWidth)/2
  199.   printer (mSetTextSize,24)
  200.   
  201.   printer (mSetTextJust,"left")
  202.   printer (mdrawText,mapName,35,55)
  203.   
  204.   -- this part sends the tour bitmap to the appendBitMap procedure --
  205.   set whatToPrint="tour"
  206.   set theBitMap=the value of line 2 of field "MaxField"
  207.   --set ww=the width of member theBitMap
  208.   
  209.   appendBitMap theBitMap,235,70,"tour"
  210.   
  211.   -- this part prints the text of the tour --
  212.   --if the number of lines of field "MaxField">3 then
  213.   
  214.   --printer (mNewPage)
  215.   printer (mSetTextJust,"left")
  216.   printer (mSetTextStyle,"plain")
  217.   printer (mTextBox,35,60,w,h,TRUE)
  218.   printer (mSetTextSize,16)
  219.   
  220.   repeat with i=3 to the number of lines of field "MaxField"
  221.     set tourtext=line i of field "MaxField"
  222.     AppendStyledText (printer,the value of tourtext, TRUE)
  223.   end repeat
  224.   --end if
  225.   printingProc
  226. end
  227.  
  228. on MySetUp 
  229.   -- MySetUp sets up the page in a standard mode, including logo and pages --
  230.   global printer,w,h,gPropFont
  231.   printer (mSetLandScapemode,FALSE)
  232.   printer (mSetMargins,72,72,72,72)
  233.   put printer(mGetPageWidth) into w
  234.   put printe